<template>
    <el-container class="auth_setting_container">
        <el-main>
            <el-card class="box-card">
                <el-divider content-position="left" class="title">权限设置</el-divider>
                <setting-form type="global_setting" :rules="globalRules" :fields="globalFields"
                              label-width="150px" @event="handleGlobalEvent"/>
            </el-card>
        </el-main>
    </el-container>
</template>

<script>
export default {
    name: "AuthSetting",
    components: {
        SettingForm: () => import("@common/views/common/SettingForm"),
    },
    data() {
        return {
            globalRules: {},
            globalFields: [
                {
                    label: '数据范围授权',
                    prop: 'enable_data_auth',
                    type: 'radioGroupButton',
                    defaultValue: 0,
                    children: [
                        {value: 1, name: '开启'},
                        {value: 0, name: '关闭'},
                    ],
                },
                {
                    label: '数据字段授权',
                    prop: 'enable_data_auth_field',
                    type: 'radioGroupButton',
                    defaultValue: 0,
                    children: [
                        {value: 1, name: '开启'},
                        {value: 0, name: '关闭'},
                    ],
                },
                {
                    label: '往来单位显示',
                    prop: 'related_party_display',
                    type: 'radioGroupButton',
                    defaultValue: 'name',
                    children: [
                        {value: 'code', name: '编码'},
                        {value: 'name', name: '名称'},
                        {value: 'short_name', name: '简称'},
                    ],
                },
            ],
        };
    },
    methods: {
        handleGlobalEvent(event) {
            const _this = this;
            if (event.type === 'success') {
                _this.fetchDataNoCatch(_this.$api.API_ClearGlobalSettingCache).then(() => {
                    _this.storeDispatch('initGlobalSetting');
                });
            }
        },
    },
}
</script>

<style lang="less" rel="stylesheet/less" scoped>
.auth_setting_container {
    width: 100%;
    height: 100%;
    overflow: hidden;

    .title {

        .el-divider__text {
            font-size: 20px;
            font-weight: bold;
        }
    }
}
</style>
